package com.asm.controller.api;

import com.asm.controller.BaseController;
import com.asm.dto.PageResult;
import com.asm.dto.Result;
import com.asm.service.ContractContainService;
import com.asm.vo.sys.ContractContainVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @author tanzujie
 */
@RestController
public class ContractContainController extends BaseController {
    @Resource
    private ContractContainService contractcontainService;

    /**
     * 分页查询所有合同包含
     *
     * @param pageNumber 当前页码
     * @param pageSize   页面大小
     * @return 合同包含
     */
    @ApiOperation("接口描述:查询所有合同包含")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "当前页码"),
            @ApiImplicitParam(name = "pageSize", value = "分页大小")
    })
    @GetMapping("/contractcontains")
    public ResponseEntity<PageResult<ContractContainVo>> getAllContractContains(@RequestParam(value = "pageNumber", defaultValue = "0") Integer pageNumber, @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findAllContractContains(pageNumber, pageSize)), HttpStatus.OK);
    }

    /**
     * 根据Id获取合同包含
     *
     * @param id 合同包含编号
     * @return 合同包含
     */
    @ApiOperation("接口描述:根据Id获取合同包含")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "合同包含编号")
    })
    @GetMapping("/contractcontain/{id}")
    public ResponseEntity<Result<ContractContainVo>> getContractContainById(@PathVariable("id") Long id) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findContractContainById(id)), HttpStatus.OK);
    }

    /**
     * 根据合同编号分页查询编号合同包含
     *
     * @param contractid 合同包含
     * @param pageNumber 当前页码
     * @param pageSize   页面大小
     * @return 合同包含
     */
    @ApiOperation("接口描述:根据合同编号分页查询编号合同包含")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "contractId", value = "合同编号"),
            @ApiImplicitParam(name = "pageNumber", value = "当前页码"),
            @ApiImplicitParam(name = "pageSize", value = "分页大小")
    })
    @GetMapping("/contractcontains/contractid/{contractid}")
    public ResponseEntity<PageResult<ContractContainVo>> getContractContainByContractId(@PathVariable("contractid") Long contractid, @RequestParam(value = "pageNumber", defaultValue = "0") Integer pageNumber, @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findContractContainByContractId(contractid, pageNumber, pageSize)), HttpStatus.OK);
    }

    /**
     * 根据广告位编号查询合同包含
     *
     * @param spotid 广告位编号
     * @return 合同包含
     */
    @ApiOperation("接口描述:根据广告位编号查询合同包含")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "spotid", value = "广告位编号")
    })
    @GetMapping("/contractcontains/spotid/{spotid}")
    public ResponseEntity<PageResult<ContractContainVo>> getContractContainBySpotId(@PathVariable("spotid") Long spotid, @RequestParam(value = "pageNumber", defaultValue = "0") Integer pageNumber, @RequestParam(value = "pageSize", defaultValue = "15") Integer pageSize) {
        return new ResponseEntity(new Result().ok("success", contractcontainService.findContractContainBySpotId(spotid, pageNumber, pageSize)), HttpStatus.OK);
    }

    /**
     * 增加合同包含
     *
     * @param contractcontainVo 合同包含对象
     * @return 操作状态
     */
    @ApiOperation("接口描述:增加合同包含")
    @PostMapping("/contractcontain/add")
    public ResponseEntity<Result> addContractContain(@RequestBody @ApiParam(name = "contractcontainVo", value = "合同包含对象") ContractContainVo contractcontainVo) {
        contractcontainService.addContractContain(contractcontainVo);
        return new ResponseEntity(new Result().ok("add success"), HttpStatus.OK);
    }

    /**
     * 更新合同包含
     *
     * @param contractcontainVo 合同包含对象
     * @return 操作状态
     */
    @ApiOperation("接口描述:更新合同包含")
    @PutMapping("/contractcontain/update")
    public ResponseEntity<Result> updateContractContain(@RequestBody @ApiParam(name = "contractcontainVo", value = "合同包含对象") ContractContainVo contractcontainVo) {
        contractcontainService.updateContractContain(contractcontainVo);
        return new ResponseEntity(new Result().ok("update success"), HttpStatus.OK);
    }

    /**
     * 根据Id删除合同包含
     *
     * @param id 合同包含编号
     * @return 操作状态
     */
    @ApiOperation("接口描述:根据Id删除合同包含")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "合同包含编号")
    })
    @DeleteMapping("/contractcontain/delete/{id}")
    public ResponseEntity<Result> deleteContractContain(@PathVariable("id") Long id) {
        contractcontainService.deleteContractContain(id);
        return new ResponseEntity(new Result().ok("delete success"), HttpStatus.OK);
    }
}
